package com.woniuxy.project115.kaer.mall.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.project115.kaer.commons.util.JwtUtil;
import com.woniuxy.project115.kaer.commons.util.Result;
import com.woniuxy.project115.kaer.mall.form.EvaluationForm;
import com.woniuxy.project115.kaer.mall.param.EvaluationParam;
import com.woniuxy.project115.kaer.mall.service.EvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单评价表 前端控制器
 * </p>
 *
 * @author lyc
 * @since 2025年02月17日
 */
@RestController
@RequestMapping("/evaluation")
@Api(tags = "订单评价接口")
public class EvaluationController {
    @Resource
    private EvaluationService evaluationService;
    //提交商品订单评价
    @ApiOperation("提交商品订单评价")
    @PutMapping("submitEvaluation")
    public Result submitEvaluation(@RequestHeader String token, EvaluationForm form) throws Exception {
        evaluationService.submitEvaluation(JwtUtil.getUserId(token),JwtUtil.parseToken(token).get("nickName", String.class), BeanUtil.toBean(form, EvaluationParam.class));
        return Result.succeed("提交成功", null);
    }
}

